package entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Sebas
 */
@Entity
@Table(name = "movie")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Movie.findAll", query = "SELECT m FROM Movie m"),
    @NamedQuery(name = "Movie.findByIdMovie", query = "SELECT m FROM Movie m WHERE m.idMovie = :idMovie"),
    @NamedQuery(name = "Movie.findByGenre", query = "SELECT m FROM Movie m WHERE m.movGenre = :movGenre"),
    @NamedQuery(name = "Movie.findByMovYear", query = "SELECT m FROM Movie m WHERE m.movYear = :movYear"),
    @NamedQuery(name = "Movie.findByMovRating", query = "SELECT m FROM Movie m WHERE m.movRating = :movRating"),
    @NamedQuery(name = "Movie.findByMovDuration", query = "SELECT m FROM Movie m WHERE m.movDuration = :movDuration"),
    @NamedQuery(name = "Movie.findByMovAvailableforrental", query = "SELECT m FROM Movie m WHERE m.movAvailableforrental = :movAvailableforrental"),
    @NamedQuery(name = "Movie.findByMovAvailableforpurchase", query = "SELECT m FROM Movie m WHERE m.movAvailableforpurchase = :movAvailableforpurchase")})
public class Movie implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id_movie")
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Integer idMovie;
    @Basic(optional = false)
    @Lob
    @Column(name = "mov_name")
    private String movName;
    @Basic(optional = false)
    @Column(name = "mov_year")
    private int movYear;
    @Basic(optional = false)
    @Lob
    @Column(name = "mov_cover")
    private String movCover;
    @Basic(optional = false)
    @Lob
    @Column(name = "mov_plotkeywords")
    private String movPlotkeywords;
    @Basic(optional = false)
    @Lob
    @Column(name = "mov_genre")
    private String movGenre;
    @Basic(optional = false)
    @Column(name = "mov_rating")
    private float movRating;
    @Basic(optional = false)
    @Column(name = "mov_duration")
    private float movDuration;
    @Basic(optional = false)
    @Column(name = "mov_availableforrental")
    private boolean movAvailableforrental;
    @Basic(optional = false)
    @Column(name = "mov_availableforpurchase")
    private boolean movAvailableforpurchase;
    @ManyToMany(mappedBy = "movieCollection")
    private Collection<Actor> actorCollection;
    @JoinColumn(name = "soundtrack_id_sountrack", referencedColumnName = "id_sountrack")
    @ManyToOne(optional = false)
    private Soundtrack soundtrackIdSountrack;
    @JoinColumn(name = "director_id_director", referencedColumnName = "id_director")
    @ManyToOne(optional = false)
    private Director directorIdDirector;

    public Movie() {
    }

    public Movie(Integer idMovie) {
        this.idMovie = idMovie;
    }

    public Movie(Integer idMovie, String movName, int movYear, String movCover, String movPlotkeywords, String movGenre, float movRating, float movDuration, boolean movAvailableforrental, boolean movAvailableforpurchase) {
        this.idMovie = idMovie;
        this.movName = movName;
        this.movYear = movYear;
        this.movCover = movCover;
        this.movPlotkeywords = movPlotkeywords;
        this.movGenre = movGenre;
        this.movRating = movRating;
        this.movDuration = movDuration;
        this.movAvailableforrental = movAvailableforrental;
        this.movAvailableforpurchase = movAvailableforpurchase;
    }

    public Integer getIdMovie() {
        return idMovie;
    }

    public void setIdMovie(Integer idMovie) {
        this.idMovie = idMovie;
    }

    public String getMovName() {
        return movName;
    }

    public void setMovName(String movName) {
        this.movName = movName;
    }

    public int getMovYear() {
        return movYear;
    }

    public void setMovYear(int movYear) {
        this.movYear = movYear;
    }

    public String getMovCover() {
        return movCover;
    }

    public void setMovCover(String movCover) {
        this.movCover = movCover;
    }

    public String getMovPlotkeywords() {
        return movPlotkeywords;
    }

    public void setMovPlotkeywords(String movPlotkeywords) {
        this.movPlotkeywords = movPlotkeywords;
    }

    public String getMovGenre() {
        return movGenre;
    }

    public void setMovGenre(String movGenre) {
        this.movGenre = movGenre;
    }

    public float getMovRating() {
        return movRating;
    }

    public void setMovRating(float movRating) {
        this.movRating = movRating;
    }

    public float getMovDuration() {
        return movDuration;
    }

    public void setMovDuration(float movDuration) {
        this.movDuration = movDuration;
    }

    public boolean getMovAvailableforrental() {
        return movAvailableforrental;
    }

    public void setMovAvailableforrental(boolean movAvailableforrental) {
        this.movAvailableforrental = movAvailableforrental;
    }

    public boolean getMovAvailableforpurchase() {
        return movAvailableforpurchase;
    }

    public void setMovAvailableforpurchase(boolean movAvailableforpurchase) {
        this.movAvailableforpurchase = movAvailableforpurchase;
    }

    @XmlTransient
    public Collection<Actor> getActorCollection() {
        return actorCollection;
    }

    public void setActorCollection(Collection<Actor> actorCollection) {
        this.actorCollection = actorCollection;
    }

    public Soundtrack getSoundtrackIdSountrack() {
        return soundtrackIdSountrack;
    }

    public void setSoundtrackIdSountrack(Soundtrack soundtrackIdSountrack) {
        this.soundtrackIdSountrack = soundtrackIdSountrack;
    }

    public Director getDirectorIdDirector() {
        return directorIdDirector;
    }

    public void setDirectorIdDirector(Director directorIdDirector) {
        this.directorIdDirector = directorIdDirector;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idMovie != null ? idMovie.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Movie)) {
            return false;
        }
        Movie other = (Movie) object;
        if ((this.idMovie == null && other.idMovie != null) || (this.idMovie != null && !this.idMovie.equals(other.idMovie))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Movie[ idMovie=" + idMovie + " ]";
    }
    
}
